package com.uzhie.web.controller.http;

import com.alibaba.fastjson.JSONObject;
import com.uzhie.web.anno.Auth;
import com.uzhie.web.bean.PayloadBean;
import com.uzhie.web.controller.http.comm.CommController;
import com.uzhie.web.module.Picture;
import com.uzhie.web.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 告警图片查看
 * Created by lilongfei on 2018/8/11.
 */

@RestController
@RequestMapping(value = "pic")
public class PictureController extends CommController {

    @Autowired
    PictureService pictureService;

    /**
     * 查询图片列表
     *
     * @param body simNumber 车载sim卡号
     *             startTime 起始时间
     *             endTime 终止时间
     *             warn 事件标识
     * @return
     */
    @Auth
    @RequestMapping(value = "queryListByCondition")
    public PayloadBean queryListByCondition(@RequestBody(required = false) JSONObject body) {
        Map<String, List<Picture>> result = pictureService.queryPicResByCondition(body.getString("simNumber"),
                body.getString("startTime"), body.getString("endTime"),
                body.getString("warn"));
        return buildResponse(result);
    }
}
